# Contributor: Jakob Meier <comcloudway@ccw.icu>
# Maintainer: Jakob Meier <comcloudway@ccw.icu>
pkgname=rnote
pkgver=0.11.0
pkgrel=0
pkgdesc="Sketch and take handwritten notes."
url="https://rnote.flxzt.net/"
# ppc64le: vendored abseil, not possible to override to system
# armhf: doesn't build
# s390x: mainframe
arch="all !armhf !s390x !ppc64le"
license="GPL-3.0-or-later"
makedepends="
	alsa-lib-dev
	appstream-glib-dev
	appstream-dev
	cargo
	cargo-auditable
	clang-dev
	cmake
	desktop-file-utils
	gtk4.0-dev
	libadwaita-dev
	meson
	poppler-dev
	"
subpackages="$pkgname-lang $pkgname-cli:cli"
source="
	https://github.com/flxzt/rnote/archive/refs/tags/v$pkgver/rnote-$pkgver.tar.gz
	use_cargo_auditable.patch
"
options="net"

export CARGO_PROFILE_RELEASE_LTO=thin

prepare() {
	default_prepare

	export CARGO_HOME="$builddir/output/cargo-home"

	cargo fetch --target="$CTARGET" --locked
	for crate in rnote-cli rnote-compose rnote-engine rnote-ui; do
		cd $builddir/crates/$crate
		cargo fetch --target="$CTARGET" --locked
	done
}

build() {
	abuild-meson \
		. output

	meson configure -Dcli=true output
	meson compile -C output
}
check() {
	meson compile cargo-test -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

cli() {
	pkgdesc="Convert files to and from .rnote"

	amove usr/bin/rnote-cli
}

sha512sums="
3a792738977a7f19c598122490d8f76a2b9f0ff348f2f65a6b9771ca3afb04cae5e9022dc6fe95883242bc7ddbf53ce742698ba709ffb4025b48ab149b21d677  rnote-0.11.0.tar.gz
7c53d5a603cc6779fa79652cfb04897901f7dc04f226686903bb56dfa55cb8a67720f611c2da80eb2d365bfbdb7a36fea29a5c63f5b62ce5f16c0830c4047aa9  use_cargo_auditable.patch
"
